/*
 * @lc app=leetcode.cn id=167 lang=cpp
 *
 * [167] 两数之和 II - 输入有序数组
 */

// @lc code=start
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        //双指针
        int i = 0, j = numbers.size() - 1;
        while(i < j){
            while(i < j && numbers[i] + numbers[j] > target) j--;
            if(i < j && numbers[i] + numbers[j] == target) return{i + 1, j + 1};
            i++;
        }
        return {};
    }
};
// @lc code=end

